﻿using Microsoft.AspNetCore.Mvc;
using Travel.Data.Inputs;
using Travel.Data;
using Travel.Service.TravelBusiness;
using Travel.API.Filters;
using Travel.Data.Dtos.TravelBusiness;
using Travel.Data.Dtos;

namespace Travel.API.Controller
{
    /// <summary>
    /// 收藏夹
    /// </summary>
    [ApiController]
    [Route("[controller]/[action]")]
    public class FavoriteController : BaseController
    {
        private readonly IFavoriteService _favoriteService;

        public FavoriteController(IFavoriteService favoriteService)
        {
            _favoriteService = favoriteService;
        }

        /// <summary>
        /// 添加收藏夹
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [TravelAuthorize]
        public async Task<Results<int>> AddFavorite([FromBody]AddFavoriteInput input)
        {
            return await _favoriteService.AddFavorite(input);
        }
        /// <summary>
        /// 查看收藏夹
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        [TravelAuthorize]
       public async Task<Results<PageDto<FavoriteDto>>> UpdateFavorite([FromBody]FavoriteQueryInput input) { 
            return await _favoriteService.UpdateFavorite(input);
        }
        /// <summary>
        /// 移除收藏夹
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet("{id}")]
        [TravelAuthorize]
       public async Task<Results<int>> RemoveFavorite(long id) { 
        
            return await _favoriteService.RemoveFavorite(id);
        }
    }
}
